import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { LayuiVueResolver } from "unplugin-layui-vue-resolver";

const excludeComponents = ['LightIcon', 'DarkIcon']

export default defineConfig({
  plugins: [
    AutoImport({
      resolvers: [
        LayuiVueResolver(),
      ],
    }),
    Components({
      resolvers: [
        LayuiVueResolver({
          resolveIcons: true,
          exclude: excludeComponents
        }),
      ],
    }),
    vue(),
  ],
  base: '/console/',
  // vite 相关配置
  server: {
    hmr: true,
    port: 9375,
    host: true,
    open: true,
    proxy: {
      '/api': {
        target: 'https://cxuu.top',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/msghub': {
        target: 'https://cxuu.top',
        ws: true,
        rewrite: (path) => path.replace(/^\/msgHub/, '')
      }
    }
  }
});